package org.boge.sharpdoc.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.boge.sharpdoc.dao.DocIconDao;
import org.boge.sharpdoc.bean.DocIcon;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class DocIconService {
    @Autowired
    private DocIconDao docIconDao;

    public PageInfo<DocIcon> getIconList(Integer index, Integer pageSize) {
        return PageHelper.startPage(index, pageSize).doSelectPageInfo(() -> docIconDao.findAll());
    }

    public boolean addNewItem(DocIcon docIcon) {
        if (docIconDao.findBySuffix(docIcon) == null) {
            docIconDao.addNewIcon(docIcon);
            return true;
        }
        return false;
    }

    public Integer deleteItem(DocIcon docIcon) {
        return docIconDao.deleteItem(docIcon);
    }

    public Integer delByBatch(String[] arr) {
        return docIconDao.delByBatch(arr);
    }
}